import 'package:flutter/material.dart';
import 'package:flutter_ncsjqz_getx/http/dio_service.dart';
import 'package:flutter_ncsjqz_getx/model/platform_msg_entity.dart';
import 'package:flutter_ncsjqz_getx/model/sys_message_detail_entity.dart';
import 'package:flutter_ncsjqz_getx/page_common/show_html_page.dart';
import 'package:flutter_ncsjqz_getx/widget/app_bar_widget.dart';
import 'package:flutter_ncsjqz_getx/widget/ink_widget.dart';

/// <summary>
/// author：zwb
/// dateTime： 2021/12/21 14:06
/// filePath： lib/page/my/message/sys_message_view.dart
/// desc: 系统公告详情
/// <summary>
///
class SysMessageView extends StatefulWidget {
  final int? sysId; // 不为空则系统消息，为空则消息阅读
  final PlatformMsgDataList? content; // 消息内容
  const SysMessageView({Key? key, this.sysId, this.content}) : super(key: key);

  @override
  _SysMessageViewState createState() => _SysMessageViewState();
}

class _SysMessageViewState extends State<SysMessageView> {
  SysMessageDetailData? data = SysMessageDetailData();
  /// 获取系统公告
  getSysNotice() async{
    SysMessageDetailEntity sysNoticeEntity = await DioService<SysMessageDetailEntity>().v2_sysNoticeDetail({"systemId":widget.sysId});
    if(sysNoticeEntity.code == 0) data = sysNoticeEntity.data;
    setState(() { });
  }
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    if(widget.content == null){
      getSysNotice();
    }
  }
  @override
  Widget build(BuildContext context) {
    return widget.content == null ?ShowHtmlPage(
      title: "${data!.msgTitle}",
      htmlStr: "${data!.msgContent}",
    ):Scaffold(
      appBar: appBarWidget(title: "消息阅读"),
      backgroundColor: Colors.white,
      body: Padding(
        padding: EdgeInsets.all(15),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            InkWidget.title("${widget.content!.msgTitle}"),
            InkWidget.text("${widget.content!.msgContent}",maxLines: 99999999999),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Column(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    InkWidget.text(""),
                    InkWidget.text("${widget.content!.createTime}"),
                  ],
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
